package com.mcxx.common.service.impl;

import com.mcxx.common.service.CheckSystemAllService;
import com.mcxx.modules.miniSalvation.family.dto.BankAccountDTO;
import com.yinhai.ta404.core.service.BaseService;
import com.yinhai.ta404.core.transaction.annotation.TaTransactional;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;

@Service
@TaTransactional
public class CheckSystemAllServiceImpl extends BaseService implements CheckSystemAllService {

    private static final Logger logger = LoggerFactory.getLogger(CheckSystemAllServiceImpl.class);


    @Override
    public Boolean checkStringParam(String... param) {
        try{
            for (String str : param) {

                if (!StringUtils.isNotBlank(str)) {
                    return false;
                }
            }
            return true;
        }catch (Exception e){
            logger.error("检查传入的参数是否有空值----->" + e.getMessage());
            e.printStackTrace();
            return false;
        }
    }

    public static void main(String[] args) {





//        System.out.println(dto.getId());
        String aa = "'1','2','3',";
        aa = aa.substring(0,aa.length()-1);
        System.out.println(aa);

        String a = "01";
        String b = "01,02";
        if(b.contains(a)){
            System.out.println("+++++++++++++");
        }
        String c = "orderSubsistenApiParam.AXDF000";
        c = StringUtils.substring(c,23);
        System.out.println(c);
    }
    public static Boolean checkStringParams(String[][] param,BankAccountDTO cl) {
        try{






            BankAccountDTO dd = new BankAccountDTO();
            cl.setId("123");
            Class clazz = cl.getClass();
            Object object =  clazz.newInstance();
            for(int i = 0;i<param.length;i++){
                String name = param[i][0];
                String value = param[i][1];
                Field field = clazz.getDeclaredField(name);
                field.setAccessible(true);
                field.set(object,value);
                break;
            }
            dd = (BankAccountDTO)object;
            cl.setId(dd.getId());
            System.out.println(cl.getId());
            return true;
        }catch (Exception e){
            logger.error("检查传入的参数是否有空值----->" + e.getMessage());
            e.printStackTrace();
            return false;
        }
    }
}
